<?php
/**
 *      [迷你云] (C)2009-2012 南京恒为网络科技.
 *   软件仅供研究与学习使用，如需商用，请访问www.miniyun.cn获得授权
 * 
 */
?>
<?php

class MiniyunViewForm extends CFormModel
{
    
    public $owner;
    public function attributeLabels()
    {
        return array(

        );
    }

    
    public function attributeFilters(){
        return array(
        );
    }
    
    public function attributeNextActions(){
        return array(
        );
    }


    
    public function covertNameToUpper($string){
        $newString = $string;
        for($i=0; $i<strlen($string); $i++){
            $str = substr($string, $i, 1);
            if($str == "_"){
                $strS = substr($string, $i, 2);
                if (strlen($strS)<=1){
                    return "";
                }
                $strP = substr($strS, 1, 1);
                $table_change = array($strS=>strtoupper($strP));
                $newString = strtr($newString,$table_change);
            }
        }
        return $newString;
    }


    
    public function covertNameToLower($string){
        $newString = $string;
        for($i=0; $i<strlen($string); $i++){
            $str = substr($string, $i, 1);
            if(preg_match('/^[A-Z]+$/', $str)){
                $table_change = array($str=>"_".strtolower($str));
                $newString = strtr($newString,$table_change);
            }
        }
        return $newString;
    }

    
    public function generateFileName($name){
        $path_parts = pathinfo($name);
                $extension = $path_parts['extension'];
        $sha1_name = sha1($name.date('U')).".".$extension;
        return $sha1_name;
    }
    
    
    
    public $_m = array();

    
    public function __get($name)
    {
                                $get_func = 'get'.$name;
        if (method_exists($this, $get_func))
        {
            return $this->$get_func();
        }
        
                                else if (isset($this->_m[$name]))
        {
            return $this->_m[$name];
        }

                                else if (isset($this->$name))
        {
            return $this->$name;
        }

                                else if (is_array($this->_m))
        {
            foreach($this->_m as $object)
            {
                if (property_exists($object,$name) || $object->canGetProperty($name))
                    return $object->$name;
            }
        }

        throw new CException(Yii::t('Property', '"{class}.{property}" is not defined.',
            array('{class}'=>get_class($this), '{property}'=>$name)));
    }

    
    public function __set($name, $value)
    {
                                $set_func = 'set'.$name;
        if (method_exists($this, $set_func))
        {
            return $this->$set_func($value);
        }

                                $this->_m[$name] = $value;
    }
}
